package br.com.aquinoevasconcelos.servlets.administrador;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import br.com.aquinoevasconcelos.fachada.Fachada;
import br.com.aquinoevasconcelos.user.UsuarioAdm;

/**
 * Servlet implementation class EncaminharPainelAdm
 */
@WebServlet("/EncaminharPainelAdm")
public class EncaminharPainelAdm extends HttpServlet {
	private static final long serialVersionUID = 1L;

    public EncaminharPainelAdm() {
        super();
    }

    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
    	Fachada fachada = Fachada.getInstancia();
		HttpSession session = request.getSession();
		UsuarioAdm adm = new UsuarioAdm();
		adm = (UsuarioAdm) session.getAttribute("sessaoAdministrador");
		
		request.setAttribute("administrador", adm);
		
		request.setAttribute("qtdInfo", fachada.QuantidadeInformativo());
		
		request.setAttribute("administradores", fachada.listaADM());
		
		RequestDispatcher rd = request.getRequestDispatcher("admin/inicio_painel.jsp");
		rd.forward(request, response);
    }
    
    
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		service(request, response);
	}


	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		service(request, response);
	}

}
